﻿Imports DTO
Imports System.Data.OleDb
Public Class BoPhanDAO

    Public Function CapNhatBoPhan(ByVal sql As String) As Integer
        DataProvider.OpenConnecttion()
        Dim kq As Integer = DataProvider.ExecInsert(sql)
        DataProvider.CloseConnect()
        Return kq
    End Function

    Public Function ThemBoPhan(ByVal sql As String) As Integer
        DataProvider.OpenConnecttion()
        Dim kq As Integer = DataProvider.ExecInsert(sql)
        DataProvider.CloseConnect()
        Return kq
    End Function

    Public Function LayDSBoPhan() As List(Of BoPhanDTO)
        Dim sql As String = "Select MaBoPhan,TenBoPhan From BOPHAN"
        DataProvider.OpenConnecttion()
        Dim reader As OleDbDataReader = DataProvider.ExecSelect(sql)
        Dim ds As New List(Of BoPhanDTO)()
        While reader.Read
            Dim bp As New BoPhanDTO()
            bp.MaBoPhan = reader.GetInt32(0)
            bp.TenBoPhan = reader.GetString(1)
            ds.Add(bp)
        End While
        DataProvider.CloseConnect()
        Return ds
    End Function
End Class
